Spread Windows Forms 9.0 Product Documentation
SortColumns(Int32,Int32,SortInfo[]) Method
Example 


Index of first column to start sorting
Number of columns in range to sort
Array of SortInfo objects with the row indexes and sort order
Sorts a specified range of columns on the sheet by the specified sort information.
Syntax
'Declaration
 
Public Overloads Function SortColumns( _
   ByVal column As Integer, _
   ByVal columnCount As Integer, _
   ByVal sortInfo() As SortInfo _
) As Boolean
'Usage
 
Dim instance As SheetView
Dim column As Integer
Dim columnCount As Integer
Dim sortInfo() As SortInfo
Dim value As Boolean
 
value = instance.SortColumns(column, columnCount, sortInfo)
public bool SortColumns( 
   int column,
   int columnCount,
   SortInfo[] sortInfo
)

Parameters

column
Index of first column to start sorting
columnCount
Number of columns in range to sort
sortInfo
Array of SortInfo objects with the row indexes and sort order

Return Value

Boolean: true if successful; false otherwise
Remarks

Use this method if you want to sort only a range of columns and not the entire sheet.

Use this method if you want to specify more than one row by which to sort. In other words, if you have more than one key for sorting.

The sortInfo array can contain multiple keys (multiple rows) and the first specified row is the primary key, etc. The sortInfo array can also contain multiple ways of comparing the sorted objects and it may be different for each key. For more information, refer to the SortInfo object.

This does not affect the data model, only how the data is displayed. Different overloads provide different ways to sort the columns. For a discussion of sorting, refer to Managing Sorting of Rows.

Example
This example sorts a range of columns.
FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[1];
sort[0] = new FarPoint.Win.Spread.SortInfo(0, false, System.Collections.Comparer.Default);
fpSpread1.ActiveSheet.SetValue(0, 0, "S");
fpSpread1.ActiveSheet.SetValue(0, 1, "E");
fpSpread1.ActiveSheet.SetValue(0, 2, "A");
fpSpread1.ActiveSheet.SetValue(0, 3, "K");
fpSpread1.ActiveSheet.SetValue(1, 0, "W");
fpSpread1.ActiveSheet.SetValue(1, 1, "G");
fpSpread1.ActiveSheet.SetValue(1, 2, "P");
fpSpread1.ActiveSheet.SetValue(1, 3, "V");
fpSpread1.ActiveSheet.SetValue(2, 0, "O");
fpSpread1.ActiveSheet.SetValue(2, 1, "L");
fpSpread1.ActiveSheet.SetValue(2, 2, "Q");
fpSpread1.ActiveSheet.SetValue(2, 3, "H");
fpSpread1.ActiveSheet.SortColumns(0, 2, sort);
Dim sort(1) As FarPoint.Win.Spread.SortInfo
sort(0) = New FarPoint.Win.Spread.SortInfo(0, True, System.Collections.Comparer.Default)
FpSpread1.ActiveSheet.SetValue(0, 0, "S")
FpSpread1.ActiveSheet.SetValue(0, 1, "E")
FpSpread1.ActiveSheet.SetValue(0, 2, "A")
FpSpread1.ActiveSheet.SetValue(0, 3, "K")
FpSpread1.ActiveSheet.SetValue(1, 0, "W")
FpSpread1.ActiveSheet.SetValue(1, 1, "G")
FpSpread1.ActiveSheet.SetValue(1, 2, "P")
FpSpread1.ActiveSheet.SetValue(1, 3, "V")
FpSpread1.ActiveSheet.SetValue(2, 0, "O")
FpSpread1.ActiveSheet.SetValue(2, 1, "L")
FpSpread1.ActiveSheet.SetValue(2, 2, "Q")
FpSpread1.ActiveSheet.SetValue(2, 3, "H")
FpSpread1.ActiveSheet.SortColumns(0, 2, sort)
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

SheetView Class
SheetView Members
Overload List
SortInfo Class

User-Task Documentation

Managing Sorting

 

 


Copyright © GrapeCity, inc. All rights reserved.